package com.gs.SynPatrolRep.model;

import com.gs.SynPatrolRep.callback.Callback;
import com.gs.SynPatrolRep.model.listener.OnResultListener;
import com.gs.SynPatrolRep.util.OKHttpUtil;

import java.lang.reflect.Type;

public class PalBillModel {
    public void getPalBills(Object query, String url,final OnResultListener listener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + url,
                query, new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        listener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        listener.onFails(e);
                    }
                }, typeofT);
    }

    public void getPalBills(String id, final OnResultListener listener, Type typeofT) {
        OKHttpUtil.getInstance().getAsync(OKHttpUtil.NET_URL + "/api/palBills?id=" + id, new Callback() {
            @Override
            public void onSuccess(Object obj) {
                listener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                listener.onFails(e);
            }
        }, typeofT);
    }

    public void getPalBillsSites(Object query, final OnResultListener listener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBills/sites",
                query, new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        listener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        listener.onFails(e);
                    }
                }, typeofT);
    }

    public void getPalBillsItems(Object bean, final OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBills/items", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                }, typeofT);
    }

    public void uploadData(Object bean, final OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBills/patrol", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                }, typeofT);
    }

    public void cancel(Object bean, final OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBills/cancel", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                }, typeofT);
    }

    public void approval(Object bean, final OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBills/approval", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                }, typeofT);
    }
}
